{% extends "index.html" %}

{% load permission_tags %}
{% load helper_tags %}

{% block scripts %}
	<script type="text/javascript" charset="utf-8">
		$(document).ready(function() {
				$( "#modulelist" ).accordion({
					autoHeight: false,
					navigation: true,
					collapsible: true,
					active: false
				});
		});
	</script>
{% endblock %}


{% block inline_navi %}
    <a href="{% url documents.views.index %}">Dokumente</a>&nbsp;>&nbsp;{{ faculty }}
{% endblock %}

{% block box_title %}
	Veranstaltungen in "{{ faculty }}"
{% endblock %}
{% block box_content %}
	<ul class="buttonbar">
		<li>
			<a class="button add" href="{% url documents.views.add_module faculty.id %}">
				Da fehlt eine Veranstaltung
			</a>
		</li>
		{% requiresobjectpermission 'documents.delete_faculty' faculty %}
			<li>
		    	<a class="button delete" href="{% url documents.views.delete_faculty faculty.id %}">
		    		Fachbereich Löschen
		    	</a>
	    	</li>
		{% endrequiresobjectpermission %}
	</ul>
	<div id="modulelist">
		{% if item_list %}
	    	{% for module, last_date, lecturer_list in item_list %}
				<h3 class="{% if not last_date %}ui-state-error{% endif %}" {% if not last_date %}title="Noch kein Upload vorhanden"{% endif %}>
					<a href="#{{ module.name }}">
						{{ module.name }}
						<div class="status">
	       					{% if last_date %}
	       						{{ last_date|naturalTimeDifference }}
	       					{% else %}
	                    		<div class="missing"></div>
	       					{% endif %}
	            		</div>
            		</a>
				</h3>
				<div>
					<ul class="buttonbar">
						<li>
							<a class="button add" href="{% url documents.views.add_module_term module.id %}">
								Da fehlt ein Semester/Dozent
							</a>
						</li>
						{% requiresobjectpermission 'documents.delete_module' module %}
							<li>
						    	<a class="button delete" href="{% url documents.views.delete_module module.id %}">
						    		Veranstaltung löschen
						    	</a>
					    	</li>
						{% endrequiresobjectpermission %}
						{% requiresobjectpermission 'documents.change_module' module %}
							<li>
						    	<a class="button change" href="{% url documents.views.change_module module.id %}">
						    		Veranstaltung umbenennen
						    	</a>
					    	</li>
						{% endrequiresobjectpermission %}
					</ul>
					<ul>
		                {% for lecturer, term_list in lecturer_list %}
		                    <li>
		                        {{ lecturer.first_name }} {{ lecturer.last_name }}
		                        <ul>
		                            {% for term in term_list %}
		                                <li>
		                                    <a href="{% url documents.views.module term.id %}">
		                                        {{ term.semester }}
		                                    </a>
		                                </li>
		                            {% endfor %}
		                        </ul>
		                    </li>
		                {% endfor %}
                	</ul>
                </div>
			{% endfor %}
	    {% endif %}
	</div>
{% endblock %}
